﻿using System;
using System.Diagnostics;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DAL;
using BusinessLayer;

namespace UnitTestLayer
{
    /// <summary>
    /// Summary description for UserTest
    /// </summary>
    [TestClass]
    public class UserTest
    {
        public UserTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void CreateUser()
        {
            //var u = new User();
            IFUserB u = new UserB();
            u.CreateUser("bent", "fucksen", "bentdrengen", "flottefyr32@hotmail.com", "snuske");

        }

        [TestMethod]
        public void SearchUsers()
        {
            IFUserB userB = new UserB();
            userB.SearchUsers("Vandb");

        }

        [TestMethod]
        public void Login()
        {
            IFUserB u = new UserB();
            u.Login("Test4", "test");
        }

        //[TestMethod]
        //public void Authenticate()
        //{

        //    IFSecurity s = new Security();
        //    s.Authenticate("Test3", "XK3JJY5JIUmK2Q1hnj8g2A==");
        //}

        [TestMethod]
        public void SaltTest()
        {
            IFSecurity s = new Security();
            byte[] salt = s.CreateSalt(10);
            string stringSalt = Convert.ToBase64String(salt);
            byte[] salt2 = Convert.FromBase64String(stringSalt);
            bool v = s.CompareByteArrays(salt, salt2);
            //Debug.WriteLine(salt);
            //Debug.WriteLine(v);
            Debug.WriteLine(v);

        }

        //[TestMethod]
        //public void DeleteToken()
        //{
        //    IFTokenB s = new TokenB();
        //    s.DeleteToken(41);
        //}

        [TestMethod]
        public void AddToBlaclist()
        {
            IFUserB u = new UserB();
            u.AddToBlacklist("test4", "test5", "QWbcOKnDDEm5BQvOddoftg==");
        }

        [TestMethod]
        public void RemoveFromBlackList()
        {
            IFUserB u = new UserB();
            u.RemoveFromBlacklist("test4", "test5", "QWbcOKnDDEm5BQvOddoftg==");
        }
    }
}
